package com.SuanFa.jiangdongqi.ErFenChaZhao;

public class Gun {
    private static final int [] nums = {3,4,3,7,5,8,4,7,3,45,89,23,7,64,3,2,57,8,66,5};
    public static void main(String[] args) {
        int i= check(nums,100);
        System.out.println(i);
    }

    private static int check(int[] num, int i) {
        int start = 0;
        int end = num.length-1;
        int mid = (start+end)/2;
        while (mid>start&&mid<end){
            if (i<num[mid]){
                mid = (start+mid-1)/2;
            }else if (i==num[mid]){
                return mid;
            }else {
                mid = (mid+1+end)/2;
            }
        }
        return -1;
    }
}
